#!/usr/bin/python

from google.appengine.api import users

from HandlerBase import HandlerBase

class AdminHandlerBase(HandlerBase):

    def get(self):
        user = self.get_current_user()
        if user is None:
            dest = users.create_login_url('/admin')
            self.redirect(dest)
        else:
            if self.valid_user():
                self.admin()
            else:
                self.error(403)

    def post(self):
        self.get()

    def valid_user(self):
        return users.is_current_user_admin()

